package com.gxa.hystrix.controller;

import com.gxa.hystrix.pojo.YaoKu;
import com.gxa.hystrix.service.YaoKuService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author thinknovo
 * @version 1.0
 * @description CheckController.java
 * @date 2021/3/11 9:30
 */
@RestController
@RequestMapping(value = "yaoKu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class YaoKuController {
    @Resource
    private YaoKuService yaoKuService;

    /*
    这里类似于ribbon，提供一个对外访问的接口地址，
    然后根据serviceFeignByCheck接口来决定调用哪一个子模块服务和哪一个接口地址
     */
    @GetMapping("chaXunAll")
    public Map<String, Object> yaoKuChaXunAll() {
        return this.yaoKuService.yaoKuChaXunAll();
    }

    @PostMapping("gengXinById")
    public Map<String, Object> yaoKuGengXinById(@RequestBody YaoKu yaoKu) {
        return this.yaoKuService.yaoKuGengXinById(yaoKu);
    }

    @PostMapping("shanChuById")
    public Map<String, Object> yaoKuShanChuById(String id) {
        return this.yaoKuService.yaoKuShanChuById(id);
    }

    @PostMapping("jinHuoById")
    public Map<String, Object> yaoKuJinHuoById(int id,int jinHuoShuLiang) {
        return this.yaoKuService.yaoKuJinHuoById(id,jinHuoShuLiang);
    }
    @PostMapping("diaoRuYaoFangById")
    public Map<String, Object> yaoKuDiaoRuYaoFangById(int id,int diaoRuYaoFangShuLiang,int yaoPinShuLiang ) {
        return this.yaoKuService.yaoKuDiaoRuYaoFangById(id,diaoRuYaoFangShuLiang,yaoPinShuLiang);
    }

    @PostMapping("xinZeng")
    public Map<String, Object> yaoKuXinZeng(@RequestBody YaoKu yaoKu) {
        return this.yaoKuService.yaoKuXinZeng(yaoKu);
    }

    @PostMapping("xiaZaiMuBan")
    public Map<String, Object> yaoKuXiaZaiMuBan(HttpServletResponse response, @RequestParam("ids") List<String> ids) throws IOException {
        return this.yaoKuService.yaoKuXiaZaiMuBan(response,ids);
    }


}
